const initData = {
    a: 0,
    b: 0
}

const ADDA = "ADDA";
const ADDB = "ADDB";

const doAddA = (data) => {
console.log(2233);
    return {
        type: ADDA,
        preload: data
    }
};


const doAddB = (data) => {
    return {
        type: ADDB,
        preload: data
    }
};
const AcADDB = () => (dispatch, state) => {
    return new Promise((resolve, reject)=>{
        setTimeout(()=>{
            dispatch(doAddB(123));
            resolve(1);
        },4000)
    });
}; 

export default (init = initData, action) => {
console.log(action);
    switch(action.type){
        case ADDA:
            return Object.assign({}, init, {a: init.a + action.preload});break;
        case ADDB:
            return Object.assign({}, init, {b: init.b + action.preload});break;
        default:
            return init;break;        
    }
}

export {doAddA, AcADDB}


